package com.adee.java;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public class Test050__lambda_filter {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        // 测试filter没有命中时会不会返回null，答：不返回null，而返回一个空list
        List<String> filter = list.stream().filter(e -> e.equals("d")).collect(Collectors.toList());
        System.out.println(filter);

        // 测试findAny
        Optional<String> d = list.stream().filter(e -> e.equals("d")).findAny();
        System.out.println(d.isPresent());
    }
}
